#ifndef __MACROS_H__
#define __MACROS_H__

#define SAFE_DELETE(p)           do { if(p) { delete (p); (p) = nullptr; } } while(0)
#define SAFE_DELETE_ARRAY(p)     do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
#define SAFE_DELETE_VECTOR(v)	 do { for (size_t i =0; i < v.size(); i++) { SAFE_DELETE(v[i]) } v.clear(); } while(0)
#define SAFE_FREE(p)             do { if(p) { free(p); (p) = nullptr; } } while(0)
#define RETURN_IF(cond)          do { if(cond) return; } while(0)
#define RETURN_TRUE_IF(cond)     do { if(cond) return true; } while(0)
#define RETURN_FALSE_IF(cond)    do { if(cond) return false; } while(0)
#define RETURN_NULL_IF(cond)     do { if(cond) return nullptr; } while(0)
#define BREAK_IF(cond)           if(cond) break;



#ifdef MESSAGECENTEREXPORT
    #ifdef WIN32
        #define MESSAGECENTER_API __declspec(dllexport)
    #else
        #define MESSAGECENTER_API __attribute ((visibility("default"))) 
    #endif
#else
    #ifdef WIN32
        #define MESSAGECENTER_API __declspec(dllimport)
    #else
        #define MESSAGECENTER_API
    #endif
#endif


/* 
 * 消息队列只设置紧急消息、普通消息两种
 *      紧急消息将消息放在队列最前面
 *      普通消息放在消息队列后面排队执行
 */
enum class MessagePriority : unsigned char
{
    MP_EMERGENCY,
    MP_COMMON
};



#endif // __MACROS_H__